import 'package:flutter/material.dart';

class ShowLargeImage extends StatelessWidget {
  ShowLargeImage(this.image);

  final Image image;

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Positioned(
          child: Container(
            color: Colors.black,
          ),
        ),
        Center(
          child: Container(
            width: MediaQuery.of(context).size.width,
            child: InteractiveViewer(
              child: image,
            ),
          ),
        ),
        Positioned(
          left: 10,
          top: MediaQuery.of(context).padding.top + 10,
          child: IconButton(
            padding: EdgeInsets.zero,
            color: Colors.black12,
            icon: Icon(
              Icons.close,
              color: Colors.white,
            ),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
        ),
        // Positioned(
        //   bottom: 20,
        //   right: 20,
        //   child: FlatButton(
        //     padding: EdgeInsets.zero,
        //     color: Colors.black12,
        //     child: Icon(
        //       Icons.download_sharp,
        //       color: Colors.white,
        //     ),
        //     onPressed: () => _saveImage(),
        //   ),
        // ),
      ],
    );
  }
//
// Future<ui.Image> _loadImageByProvider(
//   ImageProvider provider, {
//   ImageConfiguration config = ImageConfiguration.empty,
// }) async {
//   Completer<ui.Image> completer = Completer<ui.Image>();
//   ImageStreamListener listener;
//   ImageStream stream = provider.resolve(config);
//   listener = ImageStreamListener((ImageInfo frame, bool sync) {
//     final ui.Image image = frame.image;
//     completer.complete(image);
//     stream.removeListener(listener);
//   });
//   stream.addListener(listener); //添加监听
//   return completer.future; //返回
// }
}
